package com.kolalo.interactive;

import java.util.HashMap;

public class Container {
	protected static HashMap<String, Object> map = new HashMap<String, Object>();
	
	public static void Add(String name,Object value) throws Exception {
		try {
			map.put(name,value);
		} catch (Exception ex) {
			throw new Exception(ex.getMessage(),ex);
		}
	}
	
	public static void remove(String name) throws Exception {
		try {
			if(map.containsKey(name)) {
				map.remove(name);	
			}
		} catch (Exception ex) {
			throw new Exception(ex.getMessage(),ex);
		}
	}
	
	public static Object getValueByName(String name) throws Exception {
		try {
			if(map.containsKey(name)) {
				return map.get(name);	
			}
			return null;
		} catch (Exception ex) {
			throw new Exception(ex.getMessage(),ex);
		}
	}
	
	public static boolean update(String name,Object value) throws Exception {
		try {
			if(map.containsKey(name)) {
				Add(name,value);
			}else {
				map.put(name,value);
			}
			return true;
		} catch (Exception ex) {
			return false;
		}
	}
}
